package pl.edu.pw.perg.compinfodb.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import pl.edu.pw.perg.compinfodb.entities.ConnectorName;
import pl.edu.pw.perg.compinfodb.entities.ElementType;

public class ConnectorNameDAO extends GenericSpringDAO<ConnectorName> implements IConnectorNameDAO {

	public List<ConnectorName> findConnectorNamesByTypeAndFlag(ElementType et, boolean io){
		Session s = getSession();
		Query q = s.createQuery("from ConnectorName cn where cn.type = :type and cn.io = :inputFlag");
		q.setParameter("type", et).setBoolean("inputFlag", io);
		List<ConnectorName> l = q.list();
		return l;
		
	}

	@Override
	public void deleteAll() {
		Session s = getSession();
	    Query q = s.createQuery("delete from ConnectorName"); 
	    q.executeUpdate();
	}
	
	@Override
	public List<ConnectorName> findAll() {
		Session s = getSession();
	    Query q = s.createQuery("from ConnectorName"); 
	    List<ConnectorName> l = q.list();
		return l;
	}
}
